#include<iostream>
#include<iomanip>
#include<time.h>
#include<math.h>

using namespace std;

#define height 10

struct U{
  double u[4];
}Area[height][3*height];

struct var{
  double rho, u, v, p;
}vars[height][height*3];

var U2var(U in){
  var out;
  out.rho = in.u[0];
  out.u = in.u[1]/in.u[0];
  out.v = in.u[2]/in.u[0];
  out.p = 0.4*( in.u[3] -( in.u[2]*in.u[2] + in.u[1]*in.u[1] )/ (in.u[0]*2) );
return out;
}

U var2U(var in){
  U out;
  out.u[0]=in.rho;
  out.u[1]=in.rho*in.u;
  out.u[2]=in.rho*in.v;
  out.u[3]=(in.p/0.4)+(in.u*in.u+in.v*in.v)*in.rho/2;
  return out;
}

void init(){
  U start;
  var startvar;
  startvar.rho = 1.4;
  startvar.u = 3.0;
  startvar.v = 0;
  startvar.p=1;
  start = var2U(startvar);
  for(int i =0;i<height;i++)
	for(int j=0;j<height*3;j++)
	  {
		if(i>=height/5||j<height*3./5.)
		  Area[i][j]=start;
	  }
}
double maxeigen()
{
  double eigen = 0;
  double a;
  var t;
  for(int i =0;i<height;i++)
	for(int j =0;j<height*3;j++)
	  {
		if(i>=height/5||j<height*3./5.)
		  {
			t = U2var(Area[i][j]);
			a = sqrt(1.4*t.p/t.rho);
			eigen = max(eigen,fabs(t.u));
			eigen = max(eigen,fabs(t.v));
			eigen = max(eigen,fabs(u-a));
			eigen = max(eigen,fabs(v-a));
			eigen = max(eigen,fabs(u+a));
			eigen = max(eigen,fabs(v+a));
		  }
	  }
  return eigen;
}

void showpercentage(double per){
  cout<<"\b\b\b\b\b"<<"."<<setiosflags(ios::fixed)<<setprecision(1)<<100*per<<"%";
}

void solvestep()
{

  double T_final = 4.;
  double t =0;
  double ele = T_final/50;
  double temp;
  int pos =0;
  cout<<setprecision(5)<<0<<"%";
  while(t<T_final){
	if(t>pos*ele){
	  pos++;
	  showpercentage(t/T_final);
	}
	
	double tau = 0.2;
	  t = t+tau;
  }
  showpercentage(1);
  cout<<endl;
}

int main()
{
  init();
  double start, end;
  cout<<max(10,20)<<endl;
  start = clock();
  solvestep();
  end = clock();
  cout<<(end - start)/CLOCKS_PER_SEC<<" seconds used\n";
  return 0;
}
